package edu.msg.jthr.backend.bean;

import java.util.List;

import javax.ejb.EJB;
import javax.ejb.Stateless;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import edu.msg.jthr.backend.exception.ServiceException;
import edu.msg.jthr.backend.model.HiredCandidate;
import edu.msg.jthr.backend.repository.exception.RepositoryException;
import edu.msg.jthr.backend.repository.service.HiredCandidateRepository;
import edu.msg.jthr.backend.service.HiredCandidateService;

@Stateless(name = "HiredCandidateServiceBean", mappedName = "ejb/HiredCandidateService")
public class HiredCandidateServiceBean implements HiredCandidateService {

	@EJB
	private HiredCandidateRepository hiredCandidateRepository;
	private static Logger LOG = LoggerFactory
			.getLogger(CandidateServiceBean.class);

	@Override
	public List<HiredCandidate> getAll() throws ServiceException {
		try {
			return hiredCandidateRepository.getAll();
		} catch (RepositoryException e) {
			LOG.error("Get all Recommended Candidate error!" + e);
			throw new ServiceException("Get all Recommended Candidate error!",
					e);
		}
	}

	@Override
	public HiredCandidate getById(Long id) throws ServiceException {
		try {
			return hiredCandidateRepository.getById(id);
		} catch (RepositoryException e) {
			LOG.error("Get Hired Candidate by id error!" + e);
			throw new ServiceException("Get Hired Candidate by id error!!",
					e);
		}
	}

	@Override
	public void create(HiredCandidate obj) throws ServiceException {
		try {
			hiredCandidateRepository.create(obj);
		} catch (RepositoryException e) {
			LOG.error("Create Hired Candidate by id error!" + e);
			throw new ServiceException("Create Hired Candidate error!!",
					e);
		}
	}

	@Override
	public void delete(HiredCandidate obj) throws ServiceException {
		try {
			hiredCandidateRepository.delete(obj);
		} catch (RepositoryException e) {
			LOG.error("Delete Hired Candidate by id error!" + e);
			throw new ServiceException("Delete Hired Candidate error!!",
					e);
		}

	}

	@Override
	public HiredCandidate update(HiredCandidate obj) throws ServiceException {
		try {
			return hiredCandidateRepository.update(obj);
		} catch (RepositoryException e) {
			LOG.error("Update Hired Candidate by id error!" + e);
			throw new ServiceException("Update Hired Candidate error!!",
					e);
		}
	}

}
